package com.stress.testing.common.interceptor;

import com.stress.testing.common.conf.AgentConfig;
import com.stress.testing.common.conf.PluginConfig;

import java.lang.reflect.Method;

public interface Interceptor {
    void init(AgentConfig agentConfig, PluginConfig pluginConfig);

    PluginConfig getPluginConfig();

    AgentConfig getAgentConfig();

    default void before(Method method, Object[] args, Object zuper, Object thiz) {
    }

    default InvokeResult invoke(Method method, Object[] args, Object zuper, Object thiz) {
        return InvokeResult.invoked();
    }

    default Object after(Object result, Object[] args, Object zuper, Object thiz) {
        return result;
    }

    default Exception exception(Exception e) {
        return e;
    }

    default void afterReturning(Object result, Exception throwable) {

    }
}
